Memory management is one of the most fundamental issues of modern computer systems. Typically, a computer system will include a hierarchy of memory that ranges from a small, fast cache of main memory that is placed in front of a larger, but slower, auxiliary memory. The cache is generally implemented using a physical memory, such as RAM, while the auxiliary memory is implemented using a storage device, such as a disk drive or hard disk. Both memories are usually managed in uniformly sized units known as pages.
In order to improve performance, many computers and operating systems today implement virtual memory for the applications running on the computer. Virtual memory is where the computer system emulates that it has more physical memory than the computer system actually possesses. For example, most computer systems utilize 32-bit processors. Hence, a computer system is theoretically capable of providing a virtual memory of approximately 232 bits or approximately 4 Gigabytes, even though the physical memory is usually much smaller.
In order to provide a virtual memory of this size, the computer system runs the application or process in a memory address space that is virtual, i.e., not tied to the physical memory. The computer system will then swap pages in and out of a cache in its physical memory in order to emulate the virtual memory. During operation, an application or process will continually requests pages using virtual memory addresses. In response, the computer system will translate the virtual memory address into a physical memory address and determine if the page is present in the cache (i.e., the page is resident). When a requested page is not present in the cache, it is called a cache “miss” (or page fault), and the requested page must be retrieved from storage. However, when the cache is full, before a new page can be brought into the cache, another page (known as the victim page) must be evicted to storage. Typically, an operating system will use a global page replacement algorithm, such as “least recently used,” to share its physical memory with multiple algorithms.
Unfortunately, the use of virtual memory by operating systems makes applications unaware of the competition for space in the physical memory. That is, conventional operating systems will unilaterally determine how to manage the physical memory. Applications are thus forced to trust that the operating system can efficiently manage its physical memory for them.
However, in modern computing environments, applications utilize a large amount of their virtual memory. For example, applications, such as web browsers and database applications, often use large amounts of their virtual memory for uncompressed data. In addition, the workloads of many applications, such as interactive applications, can be unpredictable and cause the operating system to consume most or all of its physical memory. This can result in heavy paging activity by the operating system between its memory and secondary storage in order swap in/out pages for the applications.
Paging activity seriously degrades the performance of applications, because the cost of I/O between memory and storage is quite high. In many instances, an application could have performed better by freeing some of its memory before heavy paging activity by the operating system. For example, it is often faster for an application to recalculate/reprocess its cached data than to swap it out and back from storage. In particular, a web browser can often decompress an image much faster than having it paged out and back from storage. In general, applications are in the better position to determine which of their data should be swapped in/out or freed and reprocessed. However, as noted above, conventional operating systems manage memory unilaterally, without the cooperation of the applications.
Accordingly, it would be desirable to provide a mechanism in which applications and an operating system could efficiently share memory. It would also be desirable to provide mechanisms in which an operating system and applications could cooperatively manage the memory of the computer system.